package com.hexun.es.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.hexun.es.dao.EsDao;
import com.hexun.es.model.Person;
import com.hexun.es.service.EsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @description: es接口实现
 * @author:yrw
 * @date 2018/11/20
 */
@Service
public class EsServiceImpl implements EsService {

    @Autowired
    private EsDao esDao;

    @Override
    public boolean createIndex(String index) {
        return esDao.createIndex(index);
    }

    @Override
    public boolean deleteIndex(String index) {
        return esDao.deleteIndex(index);
    }

    @Override
    public Map<String, Object> searchById(String index, String type, String id) {
        return esDao.searchById(index, type, id);
    }

    @Override
    public void updateById(JSONObject data, String index, String type, String id) {
        esDao.updateById(data, index, type, id);
    }

    @Override
    public String addData(JSONObject data, String index, String type, String id) {
        return esDao.addData(data, index, type, id);
    }

    @Override
    public void deleteById(String index, String type, String id) {
        esDao.deleteById(index, type, id);
    }

    @Override
    public boolean isIndexExist(String index) {
        return esDao.isIndexExist(index);
    }

    @Override
    public  List<Map<String,Object>> searchPerson(Integer pageNo, Integer pageSize, String fieldSort, String sortOrder, Person p) {
        return esDao.searchPerson(pageNo, pageSize, fieldSort, sortOrder, p);
    }
}
